import 'package:json_annotation/json_annotation.dart';
import 'package:lovify/models/enums/im_state.dart';

part 'im_message.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class IMMessage<T> {
  final T? payload;
  final IMState? state;

  IMMessage({
    this.state,
    this.payload,
  });

  factory IMMessage.fromJson(Map<String, dynamic> json) =>
      _$IMMessageFromJson(json, (json) => json as T);

  Map<String, dynamic> toJson() => _$IMMessageToJson(this, (json) => json);
}
